
#ifndef GRAVBODY_H
#define GRAVBODY_H

// For critical section / semaphore usage
#include <windows.h>
#include <winnt.h>

#include <iostream>
#include <list>
#include "Vec3f.h"
#include "Geosphere.h"

using namespace std;

class GravBody {

	public:
		void init(int pID, Vec3f loc, Vec3f vel, float rad, float mass);
		void init(int pID, Vec3f loc, Vec3f vel, float rad, float mass, float rotAxis, float rotInc);
		void updateWithForce(Vec3f f, float timeScale);
		void updateHistory(float timePass);
		void updateFuture(Vec3f f, float timePass);
		void updateRotation(float timePass);
		void alterTerrain();

		const Vec3f* getLoc();
		const Vec3f* getOldLoc();
		const Vec3f* getVel();
		const Vec3f* getForce();
		const int getID();
		const float getRad();
		const float getMass();
		const float getMassSqr();
		const float getInvMassSqr();
		const int getMaxDetail();
		const list<Vec3f>* getHistory();
		const list<Vec3f>* getFuture();
		Geosphere* getGeosphere();
		Vec3f getGfxLoc();

		void setVel(Vec3f* vel);
		void setLoc(Vec3f* loc);
		void setForce(Vec3f* f);
		void acceptMass(GravBody* g);

		//void getHistoryAccess(bool enter);
		void clearHistory();

		float getRotationAxis();
		float getCurRotation();

	protected:
		int ID;
		//Geosphere* gGeo;
		Vec3f vLoc, oldLoc;
		Vec3f vVel;
		Vec3f force;
		float fRad;
		float fMass;
		float fMassSqr;
		float fInvMassSqr;
		float rotationAxis, rotationInc;
		float curRotation;
		list<Vec3f> history;
		list<Vec3f> future;
		float historyTime;
		int maxDetail;
		
		//CRITICAL_SECTION historyCS;

};

#endif